package pl.edu.agh.podyplomowe;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TripsManager {
	
	List<Trip> trips = new ArrayList<Trip>();
	
	public void addTrip(Trip trip) {
		trips.add(trip);
	}
	
	public List<Trip> getTrips() {
		return trips;
	}

	public Object findTrip(String string) {
		Trip result = null;
		List <Trip> tripList = this.getTrips();
		for(Trip t : tripList){
			if(t.getName().equals(string)){
				result = t;
			}else if(t.getDescription().equals(string)){
				result = t;
			}else if(result == null){
				for(Photo p : t.getPhotos()){
					if(p.getComment().equals(string)){
						result = t;
					}
				}
			}
		}
		return result;
	}
	
	public void removeTrip(Trip trip){
		trips.remove(trip);
	}

}
